package com.csk.zsk.compents.dao.impl;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.Criterion;
import org.springframework.stereotype.Repository;

import com.csk.zsk.commons.dao.impl.BaseHibernateDao;
import com.csk.zsk.commons.orm.Page;
import com.csk.zsk.commons.orm.PropertyFilter;
import com.csk.zsk.commons.orm.PropertyFilter.MatchType;
import com.csk.zsk.compents.dao.NewsDao;
import com.csk.zsk.compents.entity.News;

@Repository
public class NewsDaoImpl extends BaseHibernateDao<News, String> implements NewsDao {

	@Override
	public News getTop1() {
		List<News> list = this.createQuery("from News news where news.istop=true order by news.time desc").setMaxResults(1).list();
		if(list!=null&&list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
	}

	@Override
	public List<News> getNewsByTypeByTime(String type, int length) {
		return this.createQuery("from News news where news.type=? order by news.time desc",type).setMaxResults(length).list();
	}

	@Override
	public List<News> getNewsByTime(int length) {
		return this.createQuery("from News news order by news.time desc").setMaxResults(length).list();
	}

	

}
